package com.unicomcz.commision;

import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.unicomcz.DetailPageAction;

public class DetailGW extends DetailPageAction
{
    private String curCommId;
    private String commRemarks;
    
    /**
     * @return the commId
     */
    public String getCurCommId()
    {
        return curCommId;
    }
    /**
     * @param commId the commId to set
     */
    public void setCurCommId(String commId)
    {
        this.curCommId = commId;
        HttpServletRequest request = ServletActionContext.getRequest();
        HttpSession session = request.getSession();
        List types = (List)session.getAttribute("COMM_GW");
        for (int i=0;i<types.size();i++) {
            CommType ct = (CommType)types.get(i);
            if (commId.compareTo(ct.getCommId())==0) {
                commRemarks = ct.getCommRemarks();
            }
        }
    }
    /**
     * @return the commRemarks
     */
    public String getCommRemarks()
    {
        return commRemarks;
    }
    /**
     * @param commRemarks the commRemarks to set
     */
    public void setCommRemarks(String commRemarks)
    {
        this.commRemarks = commRemarks;
    }
    public String getSqlStr() {
        String sqlStr="SELECT depart_id 代理商,acct_month 月份,brand 品牌,brand_sub 子品牌,user_id 用户编号,serial_number 号码,open_time 开户时间,comm_id 佣金编号,comm_name 佣金名, " + 
                "       comm_rule 计算规则,product_id 套餐编号,product_name 套餐名,status 状态,flag_3w 是否3无,gprs GPRS费用,hf 话费,yj 佣金 " + 
                "  FROM dls_detail_comm " + 
                " WHERE depart_id = ? AND acct_month=? AND comm_id=?";
        return sqlStr;
    }
    public Object[] getParams() {
        return new Object[]{userInfo.getDepartCode(),acctMonth,curCommId};
    }
    protected void regQueryParam() throws Exception{
        if ((acctMonth==null)||(acctMonth.length()==0)) {
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM");
            acctMonth=sf.format(new java.util.Date());
        }
        pstmt.setString(1, userInfo.getDepartCode());
        pstmt.setString(2, acctMonth);
        pstmt.setString(3, curCommId);
    }
    protected void rs2List(ResultSet rs,List out) throws Exception{
        CommDetailBean t = new CommDetailBean();
        t.setDepartId(rs.getString(1));
        t.setAcctMonth(rs.getString(2));
        t.setBrand(rs.getString(3));
        t.setBrandSub(rs.getString(4));
        t.setUserId(rs.getString(5));
        t.setSerialNumber(rs.getString(6));
        t.setOpenTime(rs.getString(7));
        t.setCommId(rs.getString(8));
        t.setCommName(rs.getString(9));
        t.setCommRule(rs.getString(10));
        t.setProductId(rs.getString(11));
        t.setProductName(rs.getString(12));
        t.setStatus(rs.getString(13));
        t.setFlag3W(rs.getString(14));
        t.setGprs(rs.getString(15));
        t.setHf(rs.getString(16));
        t.setYj(rs.getString(17));
        out.add(t);
    }
}
